package com.wangtongxiao.controller.advice;

import com.wangtongxiao.controller.LoginController;
import com.wangtongxiao.dto.ResuDTO;
import com.wangtongxiao.exception.CRUDException;
import com.wangtongxiao.exception.Loginexception;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class MyControllerAdvice {
    @ExceptionHandler(Loginexception.class)
    public ResuDTO login(Loginexception e){
        ResuDTO resuDTO = new ResuDTO();
        resuDTO.setResult(ResuDTO.ERROR);
        resuDTO.setMess(e.getMessage());
        return resuDTO;
    }
    @ExceptionHandler(CRUDException.class)
    public ResuDTO value(CRUDException e){
        ResuDTO resuDTO = new ResuDTO();
        resuDTO.setResult(ResuDTO.SUCCESS);
        resuDTO.setMess(e.getMessage());
        return resuDTO;
    }

}
